package com.example.treelistviewdemo;

import androidx.annotation.Nullable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class Node implements Serializable {
    Node() {
        title = "";
        selection = SelectionStatus.none;
        fold = true;
        id = UUID.randomUUID().toString();
        level = 0;
        top = false;
        bottom = false;
        index = 0;
    }

    public String id;

    @Nullable
    public ArrayList<Node> children;

    public String title;

    public SelectionStatus selection;

    public boolean fold;

    @Nullable
    public Node parent;

    public int level;

    public boolean top;

    public boolean bottom;

    public int index;

    public Node copy() {
        Node node = new Node();
        node.id = id;
        node.title = title;
        node.selection = selection;
        node.fold = fold;
        node.parent = parent;
        node.level = level;
        node.top = top;
        node.bottom = bottom;
        node.index = index;
        if (children != null) {
            ArrayList<Node> _children = new ArrayList<>();
            for (Node child: children) {
                _children.add(child.copy());
            }
            node.children = _children;
        }
        return node;
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        return super.equals(obj);
    }
}



